
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.next();
        String str2 = scanner.next();
        if (str1.length() < str2.length()) {
            String tmp = str1;
            str1 = str2;
            str2 = tmp;
        }
        int n = str1.length();
        int m = str2.length();
        str1 = " " + str1;
        str2 = " " + str2;

        int[][] dp = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            dp[i][0] = i;
        }
        for (int j = 1; j <= m; j++) {
            dp[0][j] = j;
        }

        for (int i = 1; i <= n; i++) {
            char ch1 = str1.charAt(i);
            for (int j = 1; j <= m; j++) {
                char ch2 = str2.charAt(j);
                if (ch1 == ch2) {
                    dp[i][j] = dp[i - 1][j - 1];
                } else {
                    dp[i][j] = dp[i - 1][j] + 1;
                }
            }
        }

        //sdfads
        System.out.println(dp[n][m]);
    }
}

/*
lkjfdasfieajklsdfaeiklds
 */

//sdjakfkld

//abcdghefg
//abcdefg
//
//import java.util.Scanner;
//
//public class Main {
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        String str1 = scanner.next();
//        String str2 = scanner.next();
//        if(str1.length() > str2.length()) {
//            String t = str1;
//            str1 = str2;
//            str2 = t;
//        }
//        int cnt = str2.length()-str1.length();
//        for(int i =0 ;i<str1.length(); i++) {
//            if(str1.charAt(i) != str2.charAt(i)) {
//                cnt++;
//            }
//        }
//        System.out.println(cnt);
//    }
//}















